using GLib;

namespace Malem {
	protected class Util: GLib.Object {
		public static void sortArrayListByString(Gee.ArrayList<string> al, int left, int right) {
			if (left>=right) return;

			string midterm = al.get(left);
			string tmp;
			int l=left;
			int r=right;
			while (left<right) {
				while (left<right && al.get(right)>=midterm) --right;
				tmp = al.get(left);
				al.set(left, al.get(right));
				al.set(right, tmp);
				while (left<right && al.get(left)<=midterm) ++left;
				tmp = al.get(left);
				al.set(left, al.get(right));
				al.set(right, tmp);
			}
			sortArrayListByString(al, l, left-1);
			sortArrayListByString(al, left+1, r);
		}

		public static bool isSubSetString(Gee.ArrayList<string> biggerSet, Gee.ArrayList<string> smallSet) {
			int i=0;
			int sz = biggerSet.size;
			foreach(string s in smallSet) {
				while (i<sz && s!=biggerSet.get(i)) i++;
				if (i==sz) return false;
			}
			return true;
		}
	}
}
